package com.tbit.uqbike.client.service.impl;

import com.tbit.uqbike.client.dao.core.CouponMealDao;
import com.tbit.uqbike.client.dao.log.UserMealLogDao;
import com.tbit.uqbike.client.pojo.newEntity.CouponMeal;
import com.tbit.uqbike.client.pojo.newEntity.UserMealLog;
import com.tbit.uqbike.client.service.CouponMealService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Author: chen
 * @Description: 优惠券套餐
 * @Date: 创建于 17:21 2021/5/24
 */
@Service
public class CouponMealServiceImpl implements CouponMealService {
    @Autowired
    private CouponMealDao couponMealDao;
    @Autowired
    private UserMealLogDao userMealLogDao;

    @Override
    public List<CouponMeal> getByAccountId(Integer accountId) {
        return couponMealDao.getByAccountId(accountId);
    }

    @Override
    public CouponMeal getByMealId(Integer mealId) {
        return couponMealDao.getByMealId(mealId);
    }

    @Override
    public List<UserMealLog> queryPage(Integer userId, Integer pageNO, Integer rowCount) {
        Map<String, Object> map = new HashMap<>();
        map.put("userId", userId);
        map.put("rowCount", rowCount);
        map.put("pageNO", (pageNO - 1) * rowCount);

        return userMealLogDao.queryPage(map);
    }

    @Override
    public Integer queryCount(Integer userId) {
        return userMealLogDao.queryCount(userId);
    }
}
